﻿/*
* Activity Tracking Log v0.1.1 - http://activitytrackinglog.codeplex.com
* Activity Tracking Log for ASP.Net & ASP.Net MVC
* Copyright (c) 2011 Vadim Burac
* Licensed under the Microsoft Public License (Ms-PL)
* http://activitytrackinglog.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ActivityTrackingLog.Utils;

namespace ActivityTrackingLog.Web.Helpers.ViewEngines
{
    internal class ChartDataRenderer<T> : BaseRenderer<T> where T : class
    {
        public ChartDataRenderer() : base(HtmlHelper.ViewTypeEnum.Data, HtmlHelper.ReportTypeEnum.Chart) { }

        public override string RenderContent()
        {
            int totalRecords = 0;
            var flatList = _logRepository.GetFlatList<T>(base.UserId, base.PageIndex, base.PageSize, base.Columns, out totalRecords);

            string json = FlatListToJson(base.Columns.Select(c => c.Name).ToArray(), flatList);

            return json;
        }

    }
}
